# 导包

import requests

# 创建封装接口的类
import app


class EmpApi:
    def __init__(self):
        self.url_all = app.BASE_HOST + "/api/sys/user"
        self.url_one = app.BASE_HOST + "/api/sys/user/"

    # 封装新增员工的接口
    def add_emp(self, token, json_dirt):
        header_dirt = {"Authorization": token}
        return requests.post(url=self.url_all, headers=header_dirt, json=json_dirt)

    # 封装查询员工的接口
    def chaxun_emp(self, token, id):
        header_dirt = {"Authorization": token}
        return requests.get(url=self.url_one + str(id), headers=header_dirt)

    # 封装修改员工的接口
    def update_emp(self, token, id, json_dirt):
        header_dirt = {"Authorization": token}
        return requests.put(url=self.url_one + str(id), headers=header_dirt, json=json_dirt)


    # 封装删除员工的接口
    def del_emp(self, token, id):
        header_dirt = {"Authorization": token}
        return requests.delete(url=self.url_one + str(id), headers=header_dirt)
